var express = require('express');
var router = express.Router();
var app = express();

app.get('/test/jsonp/:jsonPath', function(req, res, next) {
	var _callback = req.query.callback;
	var _jsonPath = req.params['jsonPath'];
	console.log("_callback:" + _callback + ", _jsonPath:" + _jsonPath);
	var fs = require('fs');
	var JsonObj = JSON.parse(fs.readFileSync("test/jsonp/" + _jsonPath + ".json"));
	if (_callback) {
		res.type('text/javascript');
		res.send(_callback + '(' + JSON.stringify(JsonObj) + ')');
	} else {
		res.json(JsonObj);
	}
});
console.log("listening:3002");
app.listen(3002);
//module.exports = router;